//! Built-in functions

use crate::error::Result;

/// Built-in function registry
pub struct BuiltinFunctions;

impl BuiltinFunctions {
    /// Get current timestamp
    pub fn now() -> i64 {
        chrono::Utc::now().timestamp()
    }
    
    /// Generate random string
    pub fn random_string(length: usize) -> String {
        use rand::Rng;
        const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
                                abcdefghijklmnopqrstuvwxyz\
                                0123456789";
        let mut rng = rand::thread_rng();
        
        (0..length)
            .map(|_| {
                let idx = rng.gen_range(0..CHARSET.len());
                CHARSET[idx] as char
            })
            .collect()
    }
}
